<template>
  <Promised :promise="getUserAsync">
    <template v-slot:pending>
      <CardSkeleton title="借款人" />
    </template>
    <template v-slot>
      <a-card class="card" title="借款人" :bordered="false">
        <div class="loan-details-container">
          <!-- {{ user }} -->
          <a-descriptions title="">
            <a-descriptions-item label="姓">{{ user.first_name }}</a-descriptions-item>
            <a-descriptions-item label="手机号">{{ user.mobile | empty }}</a-descriptions-item>
            <a-descriptions-item label="出生日期">{{ user.user_info.birthday | empty }}</a-descriptions-item>：
            <a-descriptions-item label="名">{{ user.last_name }}</a-descriptions-item>
            <a-descriptions-item label="邮箱">{{ user.email }}</a-descriptions-item>
            <a-descriptions-item label="性别">{{ user.user_info.gender | gender }}</a-descriptions-item>
            <a-descriptions-item label="居住地址">{{ user.user_info | address }}</a-descriptions-item>
          </a-descriptions>

          <a-descriptions title="">
            <a-descriptions-item label="驾照号码">{{ user.user_info.driver_licence_number | empty }}</a-descriptions-item>
            <a-descriptions-item label="驾照有效期">{{ user.user_info.driver_expire_date | empty }}</a-descriptions-item>
            <a-descriptions-item label="驾照签发地">{{ user.user_info.driver_state | empty }}</a-descriptions-item>
          </a-descriptions>

          <!-- <BankTable :data="banks.data" /> -->
        </div>
      </a-card>
    </template>
  </Promised>
</template>

<script>
// import BankTable from '../table/Bank.vue'
import props from '../props'
import { getRegisterUserInfo } from '@/api/flow/user'
import { getBasiqAccounts } from '@/api/risk/basiq'

export default {
  data () {
    return {
      getUserAsync: null,

      // 用户
      user: {},

      // 银行
      banks: {},
    }
  },

  computed: {
    uid () {
      return this.loanDetails.create_user
    },
  },

  created () {
    this.getUserAsync = this.getUser()
  },

  mixins: [props],

  components: {
    // BankTable,
  },

  methods: {
    getUser () {
      return new Promise((resolve, reject) => {
        // getBasiqAccounts()
        //   .then(data => {
        //     this.banks = data
        getRegisterUserInfo(this.uid)
          .then(data => {
            this.user = data
            resolve(data)
          })
          .catch(error => {
            reject(error)
          })
          // })
          // .catch(error => {
          //   reject(error)
          // })
      })
    },
  },
}
</script>
